package com.softer.wxzj.common.util;/**
 * @author Gong Zhiyang
 * @date 2019/7/1
 */

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author Gong Zhiyang
 * @date 2019/7/1
 */
public class DepositUtil {
    private static final String FORMAT = "yyyyMMddHHmmss";
    private static int number;
    private static String startTime;

    static {
        number = 100;
        startTime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
    }

    /**
     * 生成账号
     *
     * @param num 1交存 2部分退款 3全部退款 4支用项目申请编号 5过户 6销户 7退款支付编号 8拨款支付编号 9拨款申请编号
     * z 区域申请
     * @return 账号
     */
    public static synchronized String getNo(String num) {
        String time = new SimpleDateFormat(FORMAT).format(new Date());
        if (time.equals(startTime)) {
            number++;
        } else {
            startTime = time;
            number = 100;
        }
        StringBuilder no = new StringBuilder(10);
        no.append(num).append(time).append(number);
        return no.toString();
    }
}
